package com.radiation.rms.controller;


import com.radiation.rms.common.R;
import com.radiation.rms.entity.Device;
import com.radiation.rms.service.DeviceService;
import com.radiation.rms.vo.DeviceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 设备表 前端控制器
 * </p>
 *
 * @author 1062
 * @since 2021-04-02
 */
@RestController
@RequestMapping("/rms/device")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;

    @PostMapping("query")
    public R queryDevice(@RequestBody DeviceVo deviceVo) {
        return deviceService.queryDevice(deviceVo);
    }

    @PostMapping("condition")
    public R deviceCondition(@RequestBody DeviceVo deviceVo) {
        return deviceService.deviceCondition(deviceVo);
    }

    @PutMapping("save")
    public R saveDevice(@RequestBody Device device) {
        return deviceService.saveDevice(device);
    }

    @GetMapping("get")
    public R getById(@RequestParam("deviceId") String deviceId) {
        return deviceService.getDeviceById(deviceId);
    }

    @PostMapping("update")
    public R updateDevice(@RequestBody Device device) {
        return deviceService.updateDevice(device);
    }

    @DeleteMapping("delete")
    public R removeDevice(@RequestBody List<String> deviceIds) {
        deviceService.removeByIds(deviceIds);
        return R.ok();
    }

    @GetMapping("init/mac")
    private R initMac(){
        return deviceService.initMac();
    }
}

